<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<title>新增自由列表</title>
		<link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css">
		<link rel="stylesheet" href="../static/web/css/bootstrap.min.css">
		<link rel="stylesheet" href="../static/web/css/admin.css">
		<link rel="stylesheet" href="css/codemirror.css">
		<script src="../static/web/js/jquery.min.js"></script>
		<script src="../static/web/js/bootstrap.min.js"></script>
		<script src="js/codemirror.js"></script>
		<script src="js/mode/xml/xml.js"></script>
		<script src="js/mode/javascript/javascript.js"></script>
		<script src="js/mode/css/css.js"></script>
		<script src="js/mode/htmlmixed/htmlmixed.js"></script>
		<script src="js/main.js"></script>
	</head>
	<body>
		<div id="list1" style="display:none">
			<li class="media border-bottom-dashed mt-2 py-2">
				<div class="media-body row">
					<div class="col-12 title">
						<a href="[field:arcurl/]"><h4 class="mt-0 mb-3">[field:title/]</h4></a>
					</div>
				</div>
			</li>
		</div>
		<div id="list2" style="display:none">
			<li class="media border-bottom-dashed mt-2 py-2">
				<div class="media-body row">
					<div class="col-12 title">
						[field:typelink/]
						<a href="[field:arcurl/]"><h4 class="mt-0 mb-3">[field:title/]</h4></a>
					</div>
				</div>
			</li>
		</div>
		<div id="list3" style="display:none">
			<table width="98%" cellspacing="2" cellpadding="0">
				<tr>
					<td align="center">[field:imglink/]</td>
				</tr>
				<tr>
					<td align="center">[field:textlink/]</td>
				</tr>
			</table>
		</div>
		<div id="list4" style="display:none">
			<li class="media border-bottom-dashed mt-2 py-2">
				<div class="media-body row">
					<div class="col-12 title">
						<a href="[field:arcurl/]">
							<h4 class="mt-0 mb-3">[field:title/]</h4>
						</a>
					</div>
					<div class="col-12 description py-2">
						<a href="[field:arcurl/]">[field:description/]</a>
					</div>
					<div class="col-12 addinfo">日期：[field:pubdate function="MyDate('Y-m-d', @me)"/] 浏览：[field:click/] 好评：[field:scores/]</div>
				</div>
			</li>
		</div>
		<table cellpadding="1" cellspacing="1" align="center" class="table maintable my-3">
			<form action="freelist_add.php" method="post" name="form1" onSubmit="return CheckSubmit();">
				<input type="hidden" name="dopost" value="save">
				<tr>
					<td bgcolor="#f5f5f5" colspan="2"><a href="freelist_main.php">自由列表管理</a> &gt; 添加一个列表</td>
				</tr>
				<tr>
					<td colspan="2">
						<div class="alert alert-info mb-0">自由列表标记说明：自由列表标记（freelist）的功能基本等同于arclist标记，区别是freelist标记支持分页，这让生成按自定义排序规则的文档列表（如按标题拼音部首排序等）等轻松的实现统一化管理，并且自由列是独立编译的，不与其它模板混在一起，这样不会影响系统生成网页或浏览速度</div>
					</td>
				</tr>
				<tr>
					<td width="260">自由列表标题：</td>
					<td><input type="text" name="title" id="title" class="admin-input-md"></td>
				</tr>
				<tr>
					<td>列表网页存放目录：</td>
					<td><input type="text" name="listdir" id="listdir" value="{cmspath}/a/freelist/" class="admin-input-md"> {listdir}变量的值</td>
				</tr>
				<tr>
					<td>目录默认页名称：</td>
					<td>
						<input type="text" name="defaultpage" id="defaultpage" value="index.html" class="admin-input-md">
						<label><input type="checkbox" name="nodefault" id="nodefault" value="1"> 不使用目录默认首页</label>
					</td>
				</tr>
				<tr>
					<td>命名规则：</td>
					<td><input type="text" name="namerule" id="namerule" value="{listdir}/index_{listid}_{page}.html" class="admin-input-md"></td>
				</tr>
				<tr>
					<td>列表模板：</td>
					<td>
						<input type="text" name="templet" id="templet" value="{style}/list_free.htm" class="admin-input-md">
						<button type="button" name="set4" onclick="SelectTemplets('form1.templet');" class="btn btn-success btn-sm">浏览</button>
					</td>
				</tr>
				<tr>
					<td>最大列出页数：</td>
					<td><input type="text" name="maxpage" id="maxpage" value="100" class="admin-input-sm"></td>
				</tr>
				<tr>
					<td>关键词：</td>
					<td><input type="text" name="keywords" id="keywords" class="admin-input-md"></td>
				</tr>
				<tr>
					<td>列表描述：</td>
					<td><textarea name="description" id="description" class="admin-textarea-sm"></textarea></td>
				</tr>
				<tr>
					<td colspan="2">
						<table width="98%" cellspacing="0" cellpadding="0" class="table table-borderless">
							<tr>
								<td width="25%" height="126">
									<label><img src="../static/web/img/g_t2.jpg"><input type="radio" name="liststyle" onclick="ChangeListStyle()" value="1"></label>
								</td>
								<td width="25%">
									<label><img src="../static/web/img/g_t1.jpg"><input type="radio" name="liststyle" onclick="ChangeListStyle()" value="2"></label>
								</td>
								<td width="25%">
									<label><img src="../static/web/img/g_t3.jpg"><input type="radio" name="liststyle" onclick="ChangeListStyle()" value="3"></label>
								</td>
								<td>
									<label><img src="../static/web/img/g_t4.jpg"><input type="radio" name="liststyle" onclick="ChangeListStyle()" value="4" checked></label>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td colspan="2">限定栏目：
						<?php
						echo "<select name='typeid' class='admin-input-sm'>";
						echo "<option value='0'>不限栏目</option>";
						$dsql->SetQuery("Select ID,typename, channeltype From `#@__arctype`");
						$dsql->Execute();
						while($lrow = $dsql->GetObject()){
							$disable = '';
							if ($lrow->channeltype < -1) {
								$disable = 'disabled';
							}
								echo "<option value='{$lrow->ID}' $disable>{$lrow->typename}</option>";
							}
							echo "</select>";
						?>
					</td>
				</tr>
				<tr>
					<td colspan="2">限定栏目：
						<?php
						echo "<select name='channel' class='admin-input-sm'>";
						echo "<option value='0' selected>不限</option>";
						$dsql->SetQuery("Select ID,typename From `#@__channeltype` where ID>0");
							$dsql->Execute();
							while($row = $dsql->GetObject())
							{
								echo "<option value='{$row->ID}'>{$row->typename}</option>";
							}
							echo "</select>";
						?>（如果限定了栏目文档模型，则允许使用附加表指定的列表字段作为底层变量）
					</td>
				</tr>
				<tr>
					<td colspan="2">附加属性：
						<?php
						echo "<select name='att' class='admin-input-sm'>";
						echo "<option value='0' selected>不限</option>";
						$dsql->SetQuery("SELECT * FROM `#@__arcatt`");
						$dsql->Execute();
						while($row = $dsql->GetObject())
						{
							echo "<option value='{$row->att}'>{$row->attname}</option>";
						}
						echo "</select>";
						?>
						文档发布时间：<input type="text" name="subday" id="subday2" value="0" class="admin-input-sm"> 天以内（0表示不限）
					</td>
				</tr>
				<tr>
					<td colspan="2">
						每页记录数：<input type="text" name="pagesize" id="pagesize" value="30" class="admin-input-sm">
						显示列数： <input type="text" name="col" id="col3" value="1" class="admin-input-sm">
						标题长度：<input type="text" name="titlelen" id="titlelen" value="60" class="admin-input-sm">（1字节 = 0.5个中文字）
					</td>
				</tr>
				<tr>
					<td colspan="2">
						高级筛选：<label><input type="checkbox" name="types[]" id="type1" value="image"> 带缩略图</label>
						<label><input type="checkbox" name="types[]" id="type2" value="commend"> 推荐</label>
						<label><input type="checkbox" name="types[]" id="type3" value="spec"> 专题</label>
						关键词：<input type="text" name="keywordarc" id="keywordarc">（英文逗号分开）
					</td>
				</tr>
				<tr>
					<td colspan="2">
						排列顺序：<select name="orderby" id="orderby" class="admin-input-sm">
							<option value="sortrank">置顶权限值</option>
							<option value="pubdate" selected>发布时间</option>
							<option value="senddate">录入时间</option>
							<option value="click">点击量</option>
							<option value="id">文档id</option>
							<option value="lastpost">最后评论时间</option>
							<option value="postnum">评论总数</option>
						</select>
						<label><input type="radio" name="order" value="desc" checked> 由高到低</label>
						<label><input type="radio" name="order" value="asc"> 由低到高</label>
					</td>
				</tr>
				<tr>
					<td colspan="2">循环内的单行记录样式(InnerText)支持字段(底层变量[field:varname/])：id,title,color,typeid,ismake,description,pubdate,senddate,arcrank,click,litpic,typedir,typename,arcurl,typeurl,stime(pubdate的&quot;0000-00-00&quot;格式),textlink,typelink,imglink,image普通字段直接用[field:字段名/]表示Pubdate发布时间的调用参数[field:pubdate function=MyDate('Y-m-d H:i:s',@me)/]</td>
				</tr>
				<tr>
					<td colspan="2" class="p-0">
						<textarea name="innertext" id="myinnertext" class="admin-textarea-xl"></textarea>
						<script>
							document.form1.innertext.value = document.getElementById("list4").innerHTML.toLowerCase();
						</script>
					</td>
				</tr>
				<tr>
					<td colspan="2" bgcolor="#f5f5f5" align="center"><button name="Submit2" type="submit" id="Submit2" class="btn btn-success btn-sm">保存</button></td>
				</tr>
			</form>
		</table>
		<script>
			var editor = CodeMirror.fromTextArea(document.getElementById('myinnertext'), {
				lineNumbers: true,
				lineWrapping: true,
				 mode: 'text/html'
			});
			function ChangeListStyle() {
				var itxt = document.getElementById("myinnertext");
				var myems = document.getElementsByName("liststyle");
				if (myems[0].checked) editor.setValue(document.getElementById("list1").innerHTML);
				else if (myems[1].checked) editor.setValue(document.getElementById("list2").innerHTML);
				else if (myems[2].checked) editor.setValue(document.getElementById("list3").innerHTML);
				else if (myems[3].checked) editor.setValue(document.getElementById("list4").innerHTML);
				editor.setValue(editor.getValue().replace("<BR>", "<br>"));
				editor.setValue(editor.getValue().toLowerCase());
			}
			function ShowHide(objname) {
				var obj = document.getElementById(objname);
				if (obj.style.display == "block" || obj.style.display == "")
					obj.style.display = "none";
				else
					obj.style.display = "block";
			}
			function SelectTemplets(fname) {
				var pos = GetWinPos(800,600);
				window.open("./dialog/select_templets.php?&activepath=<?php echo urlencode($cfg_templets_dir)?>&f=" + fname, "poptempWin", "scrollbars=yes,resizable=yes,statebar=no,width=800,height=600,left=" + pos.left + ", top=" + pos.top);
			}
			function CheckSubmit() {
				if (document.form1.title.value == "") {
					ShowMsg("自由列表标题标题不能为空");
					document.form1.title.focus();
					return false;
				}
				return true;
			}
		</script>
	</body>
</html>